package com.hhit.collaborative_learning.management;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import com.hhit.collaborative_learning.learning.StoreData;

/**
 * Application Lifecycle Listener implementation class ContentListener
 *
 */
@WebListener
public class ContentListener implements ServletContextListener {
	Timer timer=null;
    /**
     * Default constructor. 
     */
    public ContentListener() {
    }

	/**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent arg0) {
//    	StoreData.getBlog(1);
//    	StoreData.getBlog(2);
    	StoreData.getExperts();
//    	StoreData.getNewestExperts();
//    	StoreData.getPrimeBlog();
    	timer=new Timer(true);
    	timer.schedule(new CancelTopTask(), 0, 60*60*1000);
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0) {
    	if(timer!=null){
    		timer.cancel();
    	}
    }
	
}
